package com.j256.ormlite.android;

import com.j256.ormlite.db.DatabaseType;
import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.DatabaseFieldConfig;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.DatabaseTableConfig;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class DatabaseTableConfigUtil
{
  private static final int ALLOW_GENERATED_ID_INSERT = 24;
  private static final int CAN_BE_NULL = 5;
  private static final int COLUMN_DEFINITON = 25;
  private static final int COLUMN_NAME = 1;
  private static final int DATA_TYPE = 2;
  private static final int DEFAULT_VALUE = 3;
  private static final int FOREIGN = 9;
  private static final int FOREIGN_AUTO_CREATE = 26;
  private static final int FOREIGN_AUTO_REFRESH = 21;
  private static final int FOREIGN_COLUMN_NAME = 28;
  private static final int FORMAT = 14;
  private static final int GENERATED_ID = 7;
  private static final int GENERATED_ID_SEQUENCE = 8;
  private static final int ID = 6;
  private static final int INDEX = 17;
  private static final int INDEX_NAME = 19;
  private static final int MAX_FOREIGN_AUTO_REFRESH_LEVEL = 22;
  private static final int PERSISTED = 13;
  private static final int PERSISTER_CLASS = 23;
  private static final int READ_ONLY = 29;
  private static final int THROW_IF_NULL = 12;
  private static final int UNIQUE = 15;
  private static final int UNIQUE_COMBO = 16;
  private static final int UNIQUE_INDEX = 18;
  private static final int UNIQUE_INDEX_NAME = 20;
  private static final int UNKNOWN_ENUM_NAME = 11;
  private static final int USE_GET_SET = 10;
  private static final int VERSION = 27;
  private static final int WIDTH = 4;
  private static Class<?> annotationFactoryClazz;
  private static Class<?> annotationMemberClazz;
  private static final int[] configFieldNums = lookupClasses();
  private static Field elementsField;
  private static Field nameField;
  private static Field valueField;
  private static int workedC = 0;

  private static void assignConfigField(int paramInt, DatabaseFieldConfig paramDatabaseFieldConfig, Field paramField, Object paramObject)
  {
    switch (paramInt)
    {
    default:
      throw new IllegalStateException("Could not find support for DatabaseField number " + paramInt);
    case 1:
      paramDatabaseFieldConfig.setColumnName(valueIfNotBlank((String)paramObject));
    case 2:
    case 3:
      String str;
      do
      {
        return;
        paramDatabaseFieldConfig.setDataType((DataType)paramObject);
        return;
        str = (String)paramObject;
      }
      while ((str == null) || (str.equals("__ormlite__ no default value string was specified")));
      paramDatabaseFieldConfig.setDefaultValue(str);
      return;
    case 4:
      paramDatabaseFieldConfig.setWidth(((Integer)paramObject).intValue());
      return;
    case 5:
      paramDatabaseFieldConfig.setCanBeNull(((Boolean)paramObject).booleanValue());
      return;
    case 6:
      paramDatabaseFieldConfig.setId(((Boolean)paramObject).booleanValue());
      return;
    case 7:
      paramDatabaseFieldConfig.setGeneratedId(((Boolean)paramObject).booleanValue());
      return;
    case 8:
      paramDatabaseFieldConfig.setGeneratedIdSequence(valueIfNotBlank((String)paramObject));
      return;
    case 9:
      paramDatabaseFieldConfig.setForeign(((Boolean)paramObject).booleanValue());
      return;
    case 10:
      paramDatabaseFieldConfig.setUseGetSet(((Boolean)paramObject).booleanValue());
      return;
    case 11:
      paramDatabaseFieldConfig.setUnknownEnumValue(DatabaseFieldConfig.findMatchingEnumVal(paramField, (String)paramObject));
      return;
    case 12:
      paramDatabaseFieldConfig.setThrowIfNull(((Boolean)paramObject).booleanValue());
      return;
    case 13:
      paramDatabaseFieldConfig.setPersisted(((Boolean)paramObject).booleanValue());
      return;
    case 14:
      paramDatabaseFieldConfig.setFormat(valueIfNotBlank((String)paramObject));
      return;
    case 15:
      paramDatabaseFieldConfig.setUnique(((Boolean)paramObject).booleanValue());
      return;
    case 16:
      paramDatabaseFieldConfig.setUniqueCombo(((Boolean)paramObject).booleanValue());
      return;
    case 17:
      paramDatabaseFieldConfig.setIndex(((Boolean)paramObject).booleanValue());
      return;
    case 18:
      paramDatabaseFieldConfig.setUniqueIndex(((Boolean)paramObject).booleanValue());
      return;
    case 19:
      paramDatabaseFieldConfig.setIndexName(valueIfNotBlank((String)paramObject));
      return;
    case 20:
      paramDatabaseFieldConfig.setUniqueIndexName(valueIfNotBlank((String)paramObject));
      return;
    case 21:
      paramDatabaseFieldConfig.setForeignAutoRefresh(((Boolean)paramObject).booleanValue());
      return;
    case 22:
      paramDatabaseFieldConfig.setMaxForeignAutoRefreshLevel(((Integer)paramObject).intValue());
      return;
    case 23:
      paramDatabaseFieldConfig.setPersisterClass((Class)paramObject);
      return;
    case 24:
      paramDatabaseFieldConfig.setAllowGeneratedIdInsert(((Boolean)paramObject).booleanValue());
      return;
    case 25:
      paramDatabaseFieldConfig.setColumnDefinition(valueIfNotBlank((String)paramObject));
      return;
    case 26:
      paramDatabaseFieldConfig.setForeignAutoCreate(((Boolean)paramObject).booleanValue());
      return;
    case 27:
      paramDatabaseFieldConfig.setVersion(((Boolean)paramObject).booleanValue());
      return;
    case 28:
      paramDatabaseFieldConfig.setForeignColumnName(valueIfNotBlank((String)paramObject));
      return;
    case 29:
    }
    paramDatabaseFieldConfig.setReadOnly(((Boolean)paramObject).booleanValue());
  }

  private static DatabaseFieldConfig buildConfig(DatabaseField paramDatabaseField, String paramString, Field paramField)
    throws Exception
  {
    InvocationHandler localInvocationHandler = Proxy.getInvocationHandler(paramDatabaseField);
    Class localClass1 = localInvocationHandler.getClass();
    Class localClass2 = annotationFactoryClazz;
    DatabaseFieldConfig localDatabaseFieldConfig = null;
    if (localClass1 != localClass2);
    while (true)
    {
      return localDatabaseFieldConfig;
      Object localObject1 = elementsField.get(localInvocationHandler);
      localDatabaseFieldConfig = null;
      if (localObject1 != null)
      {
        localDatabaseFieldConfig = new DatabaseFieldConfig(paramField.getName());
        Object[] arrayOfObject = (Object[])localObject1;
        for (int i = 0; i < configFieldNums.length; i++)
        {
          Object localObject2 = valueField.get(arrayOfObject[i]);
          if (localObject2 != null)
            assignConfigField(configFieldNums[i], localDatabaseFieldConfig, paramField, localObject2);
        }
      }
    }
  }

  private static int configFieldNameToNum(String paramString)
  {
    if (paramString.equals("columnName"))
      return 1;
    if (paramString.equals("dataType"))
      return 2;
    if (paramString.equals("defaultValue"))
      return 3;
    if (paramString.equals("width"))
      return 4;
    if (paramString.equals("canBeNull"))
      return 5;
    if (paramString.equals("id"))
      return 6;
    if (paramString.equals("generatedId"))
      return 7;
    if (paramString.equals("generatedIdSequence"))
      return 8;
    if (paramString.equals("foreign"))
      return 9;
    if (paramString.equals("useGetSet"))
      return 10;
    if (paramString.equals("unknownEnumName"))
      return 11;
    if (paramString.equals("throwIfNull"))
      return 12;
    if (paramString.equals("persisted"))
      return 13;
    if (paramString.equals("format"))
      return 14;
    if (paramString.equals("unique"))
      return 15;
    if (paramString.equals("uniqueCombo"))
      return 16;
    if (paramString.equals("index"))
      return 17;
    if (paramString.equals("uniqueIndex"))
      return 18;
    if (paramString.equals("indexName"))
      return 19;
    if (paramString.equals("uniqueIndexName"))
      return 20;
    if (paramString.equals("foreignAutoRefresh"))
      return 21;
    if (paramString.equals("maxForeignAutoRefreshLevel"))
      return 22;
    if (paramString.equals("persisterClass"))
      return 23;
    if (paramString.equals("allowGeneratedIdInsert"))
      return 24;
    if (paramString.equals("columnDefinition"))
      return 25;
    if (paramString.equals("foreignAutoCreate"))
      return 26;
    if (paramString.equals("version"))
      return 27;
    if (paramString.equals("foreignColumnName"))
      return 28;
    if (paramString.equals("readOnly"))
      return 29;
    throw new IllegalStateException("Could not find support for DatabaseField " + paramString);
  }

  private static DatabaseFieldConfig configFromField(DatabaseType paramDatabaseType, String paramString, Field paramField)
    throws SQLException
  {
    if (configFieldNums == null)
      return DatabaseFieldConfig.fromField(paramDatabaseType, paramString, paramField);
    DatabaseField localDatabaseField = (DatabaseField)paramField.getAnnotation(DatabaseField.class);
    Object localObject = null;
    if (localDatabaseField != null);
    try
    {
      DatabaseFieldConfig localDatabaseFieldConfig = buildConfig(localDatabaseField, paramString, paramField);
      localObject = localDatabaseFieldConfig;
      if (localObject == null)
        return DatabaseFieldConfig.fromField(paramDatabaseType, paramString, paramField);
      workedC = 1 + workedC;
      return localObject;
    }
    catch (Exception localException)
    {
      while (true)
        localObject = null;
    }
  }

  public static <T> DatabaseTableConfig<T> fromClass(ConnectionSource paramConnectionSource, Class<T> paramClass)
    throws SQLException
  {
    DatabaseType localDatabaseType = paramConnectionSource.getDatabaseType();
    String str = DatabaseTableConfig.extractTableName(paramClass);
    ArrayList localArrayList = new ArrayList();
    for (Object localObject = paramClass; localObject != null; localObject = ((Class)localObject).getSuperclass())
    {
      Field[] arrayOfField = ((Class)localObject).getDeclaredFields();
      int i = arrayOfField.length;
      for (int j = 0; j < i; j++)
      {
        DatabaseFieldConfig localDatabaseFieldConfig = configFromField(localDatabaseType, str, arrayOfField[j]);
        if ((localDatabaseFieldConfig != null) && (localDatabaseFieldConfig.isPersisted()))
          localArrayList.add(localDatabaseFieldConfig);
      }
    }
    if (localArrayList.size() == 0)
      return null;
    return new DatabaseTableConfig(paramClass, str, localArrayList);
  }

  public static int getWorkedC()
  {
    return workedC;
  }

  // ERROR //
  private static int[] lookupClasses()
  {
    // Byte code:
    //   0: ldc_w 398
    //   3: invokestatic 402	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   6: putstatic 252	com/j256/ormlite/android/DatabaseTableConfigUtil:annotationFactoryClazz	Ljava/lang/Class;
    //   9: ldc_w 404
    //   12: invokestatic 402	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   15: putstatic 406	com/j256/ormlite/android/DatabaseTableConfigUtil:annotationMemberClazz	Ljava/lang/Class;
    //   18: ldc_w 408
    //   21: invokestatic 402	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   24: astore_1
    //   25: getstatic 252	com/j256/ormlite/android/DatabaseTableConfigUtil:annotationFactoryClazz	Ljava/lang/Class;
    //   28: ldc_w 410
    //   31: invokevirtual 414	java/lang/Class:getDeclaredField	(Ljava/lang/String;)Ljava/lang/reflect/Field;
    //   34: putstatic 254	com/j256/ormlite/android/DatabaseTableConfigUtil:elementsField	Ljava/lang/reflect/Field;
    //   37: getstatic 254	com/j256/ormlite/android/DatabaseTableConfigUtil:elementsField	Ljava/lang/reflect/Field;
    //   40: iconst_1
    //   41: invokevirtual 417	java/lang/reflect/Field:setAccessible	(Z)V
    //   44: getstatic 406	com/j256/ormlite/android/DatabaseTableConfigUtil:annotationMemberClazz	Ljava/lang/Class;
    //   47: ldc_w 419
    //   50: invokevirtual 414	java/lang/Class:getDeclaredField	(Ljava/lang/String;)Ljava/lang/reflect/Field;
    //   53: putstatic 421	com/j256/ormlite/android/DatabaseTableConfigUtil:nameField	Ljava/lang/reflect/Field;
    //   56: getstatic 421	com/j256/ormlite/android/DatabaseTableConfigUtil:nameField	Ljava/lang/reflect/Field;
    //   59: iconst_1
    //   60: invokevirtual 417	java/lang/reflect/Field:setAccessible	(Z)V
    //   63: getstatic 406	com/j256/ormlite/android/DatabaseTableConfigUtil:annotationMemberClazz	Ljava/lang/Class;
    //   66: ldc_w 423
    //   69: invokevirtual 414	java/lang/Class:getDeclaredField	(Ljava/lang/String;)Ljava/lang/reflect/Field;
    //   72: putstatic 268	com/j256/ormlite/android/DatabaseTableConfigUtil:valueField	Ljava/lang/reflect/Field;
    //   75: getstatic 268	com/j256/ormlite/android/DatabaseTableConfigUtil:valueField	Ljava/lang/reflect/Field;
    //   78: iconst_1
    //   79: invokevirtual 417	java/lang/reflect/Field:setAccessible	(Z)V
    //   82: ldc_w 425
    //   85: ldc_w 427
    //   88: invokevirtual 414	java/lang/Class:getDeclaredField	(Ljava/lang/String;)Ljava/lang/reflect/Field;
    //   91: astore 4
    //   93: aload 4
    //   95: ldc_w 341
    //   98: invokevirtual 345	java/lang/reflect/Field:getAnnotation	(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
    //   101: checkcast 341	com/j256/ormlite/field/DatabaseField
    //   104: invokestatic 246	java/lang/reflect/Proxy:getInvocationHandler	(Ljava/lang/Object;)Ljava/lang/reflect/InvocationHandler;
    //   107: astore 5
    //   109: aload 5
    //   111: invokevirtual 250	java/lang/Object:getClass	()Ljava/lang/Class;
    //   114: getstatic 252	com/j256/ormlite/android/DatabaseTableConfigUtil:annotationFactoryClazz	Ljava/lang/Class;
    //   117: if_acmpeq +18 -> 135
    //   120: aconst_null
    //   121: astore 9
    //   123: aload 9
    //   125: areturn
    //   126: astore_0
    //   127: aconst_null
    //   128: areturn
    //   129: astore_3
    //   130: aconst_null
    //   131: areturn
    //   132: astore_2
    //   133: aconst_null
    //   134: areturn
    //   135: getstatic 254	com/j256/ormlite/android/DatabaseTableConfigUtil:elementsField	Ljava/lang/reflect/Field;
    //   138: aload 5
    //   140: invokevirtual 260	java/lang/reflect/Field:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   143: astore 7
    //   145: aload 7
    //   147: ifnull +75 -> 222
    //   150: aload 7
    //   152: invokevirtual 250	java/lang/Object:getClass	()Ljava/lang/Class;
    //   155: aload_1
    //   156: if_acmpeq +6 -> 162
    //   159: goto +63 -> 222
    //   162: aload 7
    //   164: checkcast 266	[Ljava/lang/Object;
    //   167: checkcast 266	[Ljava/lang/Object;
    //   170: astore 8
    //   172: aload 8
    //   174: arraylength
    //   175: newarray int
    //   177: astore 9
    //   179: iconst_0
    //   180: istore 10
    //   182: iload 10
    //   184: aload 8
    //   186: arraylength
    //   187: if_icmpge -64 -> 123
    //   190: aload 9
    //   192: iload 10
    //   194: getstatic 421	com/j256/ormlite/android/DatabaseTableConfigUtil:nameField	Ljava/lang/reflect/Field;
    //   197: aload 8
    //   199: iload 10
    //   201: aaload
    //   202: invokevirtual 260	java/lang/reflect/Field:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   205: checkcast 112	java/lang/String
    //   208: invokestatic 429	com/j256/ormlite/android/DatabaseTableConfigUtil:configFieldNameToNum	(Ljava/lang/String;)I
    //   211: iastore
    //   212: iinc 10 1
    //   215: goto -33 -> 182
    //   218: astore 6
    //   220: aconst_null
    //   221: areturn
    //   222: aconst_null
    //   223: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   0	25	126	java/lang/ClassNotFoundException
    //   25	93	129	java/lang/SecurityException
    //   25	93	132	java/lang/NoSuchFieldException
    //   135	145	218	java/lang/IllegalAccessException
    //   150	159	218	java/lang/IllegalAccessException
    //   162	179	218	java/lang/IllegalAccessException
    //   182	212	218	java/lang/IllegalAccessException
  }

  private static String valueIfNotBlank(String paramString)
  {
    if ((paramString == null) || (paramString.length() == 0))
      paramString = null;
    return paramString;
  }

  private static class DatabaseFieldSample
  {

    @DatabaseField
    String field;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.j256.ormlite.android.DatabaseTableConfigUtil
 * JD-Core Version:    0.6.2
 */